home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / accrd1 / board.frm < prev    next >
Text File  |  1995-05-08  |  6KB  |  246 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H0000C000&
  4.    Caption         =   "Accordian"
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   855
  7.    ClientTop       =   1515
  8.    ClientWidth     =   7875
  9.    Height          =   5295
  10.    Icon            =   BOARD.FRX:0000
  11.    Left            =   795
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   4605
  15.    ScaleWidth      =   7875
  16.    Top             =   885
  17.    Width           =   7995
  18.    Begin CommandButton Command1 
  19.       Caption         =   "Deal"
  20.       Default         =   -1  'True
  21.       Height          =   1215
  22.       Left            =   6000
  23.       TabIndex        =   1
  24.       Top             =   240
  25.       Width           =   1695
  26.    End
  27.    Begin PictureBox Picture1 
  28.       AutoSize        =   -1  'True
  29.       BackColor       =   &H00FFFFFF&
  30.       BorderStyle     =   0  'None
  31.       DragMode        =   1  'Automatic
  32.       Height          =   1455
  33.       Index           =   0
  34.       Left            =   120
  35.       ScaleHeight     =   1455
  36.       ScaleWidth      =   1095
  37.       TabIndex        =   0
  38.       Top             =   120
  39.       Width           =   1095
  40.    End
  41.    Begin Menu GameMenu 
  42.       Caption         =   "&Game"
  43.       Begin Menu GameNew 
  44.          Caption         =   "&New Game"
  45.          Shortcut        =   {F2}
  46.       End
  47.       Begin Menu GameUndo 
  48.          Caption         =   "&Undo"
  49.          Shortcut        =   ^H
  50.       End
  51.       Begin Menu GameRecord 
  52.          Caption         =   "&Record of Games"
  53.       End
  54.       Begin Menu GameBar 
  55.          Caption         =   "-"
  56.       End
  57.       Begin Menu GameExit 
  58.          Caption         =   "E&xit"
  59.       End
  60.    End
  61.    Begin Menu OptionMenu 
  62.       Caption         =   "&Options"
  63.       Begin Menu OptionsErrors 
  64.          Caption         =   "Display Errors"
  65.          Checked         =   -1  'True
  66.       End
  67.       Begin Menu OptionsCompressed 
  68.          Caption         =   "Compressed"
  69.          Shortcut        =   {F5}
  70.       End
  71.    End
  72.    Begin Menu HelpMenu 
  73.       Caption         =   "Help"
  74.       Begin Menu HelpIndex 
  75.          Caption         =   "Index"
  76.          Shortcut        =   {F1}
  77.       End
  78.       Begin Menu HelpAbout 
  79.          Caption         =   "&About"
  80.       End
  81.    End
  82. End
  83. DefInt A-Z
  84.  
  85. Sub Command1_Click ()
  86.    
  87.    UndoSave'Save current state
  88.    
  89.    Piles = Piles + 1
  90.    i = Piles - 1
  91.    
  92.    Load Picture1(i)
  93.    table(Piles) = cards(NextCard)
  94.    GetCard (cards(NextCard))
  95.    Picture1(i).Picture = ClipBoard.GetData(2)
  96.    Picture1(i).Top = CurrentRow(Piles)
  97.    Picture1(i).Left = CurrentCol(Piles)
  98.    Picture1(i).Visible = -1
  99.    
  100.    NextCard = NextCard + 1
  101.    If NextCard = 53 Then
  102.      Command1.Enabled = 0
  103.    End If
  104. End Sub
  105.  
  106. Sub Form_Load ()
  107.    If CardVersion() <> 101 Then
  108.       MsgBox Appname$ + " requires VBCARDS.DLL Version 1.01P", 48, "Version Error!"
  109.       End
  110.    End If
  111.    Undone = -1
  112.    Piles = 1
  113.  
  114.    OptionsErrors.Checked = DisplayError
  115.    OptionsCompressed.Checked = Compressed
  116.    
  117.    ShuffleCards
  118.    
  119.    GetCard (cards(1))
  120.    table(1) = cards(1)
  121.    Picture1(0).Picture = ClipBoard.GetData(2)
  122.    
  123.    NextCard = 2
  124. End Sub
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. Sub GameExit_Click ()
  132.    UpdateIni
  133.    End
  134. End Sub
  135.  
  136. Sub GameNew_Click ()
  137.     NewGame
  138. End Sub
  139.  
  140. Sub GameRecord_Click ()
  141.    S$ = "Total Games is " + Str$(GamesWon + GamesLost) + Chr$(13) + Chr$(10)
  142.    S$ = S$ + "Games Won  = " + Str$(GamesWon) + Chr$(13) + Chr$(10)
  143.    S$ = S$ + "Games Lost = " + Str$(GamesLost)
  144.    MsgBox S$, 0, "Record of Games"
  145. End Sub
  146.  
  147. Sub GameUndo_Click ()
  148.     If Undone = 0 Then
  149.  
  150.        'Expand or Decrease the size of the table
  151.        If UndoPiles > Piles Then
  152.           Load Picture1(Piles)
  153.           Picture1(Piles).Top = CurrentRow(UndoPiles)
  154.           Picture1(Piles).Left = CurrentCol(UndoPiles)
  155.           Picture1(Piles).Visible = -1
  156.        Else
  157.           Unload Picture1(Piles - 1)
  158.        End If
  159.  
  160.        For i = 1 To UndoPiles
  161.           table(i) = Undoer(i)
  162.           GetCard (Undoer(i))
  163.           Picture1(i - 1).Picture = ClipBoard.GetData(2)
  164.        Next
  165.        
  166.        Piles = UndoPiles
  167.        NextCard = UndoNextCard
  168.        Undone = -1
  169.     Else
  170.        Beep
  171.     End If
  172. End Sub
  173.  
  174. Sub HelpAbout_Click ()
  175.    Form3.Show 1
  176. End Sub
  177.  
  178. Sub HelpIndex_Click ()
  179.    X = Shell("WinHelp E:\VB\Card1\Accord.hlp", 1)
  180. End Sub
  181.  
  182. Sub OptionsCompressed_Click ()
  183.     Compressed = Not Compressed
  184.     OptionsCompressed.Checked = Compressed
  185.     For i = 1 To Piles
  186.        GetCard (table(i))
  187.        Picture1(i - 1).Picture = ClipBoard.GetData(2)
  188.        Picture1(i - 1).Top = CurrentRow(i)
  189.     Next
  190.     Form1.Refresh
  191. End Sub
  192.  
  193. Sub OptionsErrors_Click ()
  194.     DisplayError = Not DisplayError
  195.     OptionsErrors.Checked = DisplayError
  196. End Sub
  197.  
  198. Sub Picture1_DblClick (Index As Integer)
  199.    If Index = 0 Then
  200.      Beep
  201.    Else
  202.      If ValidMove(Index, Index - 1) Then
  203.        UndoSave
  204.        Picture1(Index - 1).Picture = Picture1(Index).Picture
  205.        table(Index) = table(Index + 1)
  206.        Compact (Index)
  207.      Else
  208.        If Index > 2 Then
  209.          If ValidMove(Index, Index - 3) Then
  210.             UndoSave
  211.             Picture1(Index - 3).Picture = Picture1(Index).Picture
  212.             table(Index - 2) = table(Index + 1)
  213.             Compact (Index)
  214.           Else
  215.             Beep
  216.           End If
  217.        Else
  218.           Beep
  219.        End If
  220.      End If
  221.    End If
  222. End Sub
  223.  
  224. Sub Picture1_DragDrop (Index As Integer, Source As Control, X As Single, Y As Single)
  225.    If Source.Index = Index Then
  226.      Exit Sub
  227.    End If
  228.  
  229.    i% = Source.Index - Index
  230.    If Source.Index < Index Then
  231.       ShowError ("You must move cards towards the top")
  232.    ElseIf (i% <> 1) And (i% <> 3) Then
  233.       ShowError ("Card must be next to, or 4 away from target")
  234.    Else
  235.      If ValidMove(Source.Index, Index) Then
  236.        UndoSave
  237.        Picture1(Index).Picture = Source.Picture
  238.        table(Index + 1) = table(Source.Index + 1)
  239.        Compact (Source.Index)
  240.      Else
  241.        ShowError ("Card must be same suit or same value")
  242.      End If
  243.  End If
  244. End Sub
  245.  
  246.